<template>
	<view :class="pageClass" :style="pageStyle" v-if="pageReady">
		<moxi-nav :set="navSet"></moxi-nav>
		<view style="margin: 10px;">
				<u--form  :labelWidth="70"
							labelPosition="left"
							ref="uForm"
					>
						<u-form-item label="职位" borderBottom ref="item1">
									<u--input
											v-model="info.title"
											border="none"
											placeholder="输入职位名称"
									></u--input>
						</u-form-item>
						<u-form-item label="类型" borderBottom @click="showType = true;" ref="item1">
							<u--input v-model="type[info.type]" disabled placeholder="请选择职位类型" style="padding: 5px;" border="none"></u--input>
							<u-icon slot="right" name="arrow-right"></u-icon>
						</u-form-item>
						<u-form-item label="学历" borderBottom @click="showEdu = true;" ref="item1">
							<u--input v-model="edu[info.edu]" disabled placeholder="请选择学历" style="padding: 5px;" border="none"></u--input>
							<u-icon slot="right" name="arrow-right"></u-icon>
						</u-form-item>
						<u-form-item label="经验" borderBottom @click="showExp = true;" ref="item1">
							<u--input v-model="exp[info.exp]" disabled placeholder="请选择经验" style="padding: 5px;" border="none"></u--input>
							<u-icon slot="right" name="arrow-right"></u-icon>
						</u-form-item>
						<u-form-item  label="城市" borderBottom ref="item1">
							<moxi-city v-model="info" @change="change"></moxi-city>
						</u-form-item>
						<u-form-item class="xinzi" label="薪资" borderBottom ref="item1" style="text-align: center;">
							<u--input v-model="info.min_money" type="number"  placeholder="期待最低薪资"
								 border="none"></u--input>-
							<u--input v-model="info.max_money" type="number" placeholder="期待最高薪资"
								 border="none"></u--input>
						</u-form-item>
						<u-form-item  label="姓名" borderBottom ref="item1">
							<u--input v-model="info.name" border="none" placeholder="输入联系人姓名"
							></u--input>
						</u-form-item>
						<u-form-item  label="性别" borderBottom ref="item1">
							<u-radio-group v-model="info.sex" placement="row" :activeColor="app_color">
								<u-radio shape="circle" label="男" name="男" style="margin-right: 10px;"></u-radio>
								<u-radio shape="circle" label="女" name="女"></u-radio>
							</u-radio-group>
						</u-form-item>
						<u-form-item  label="电话" borderBottom ref="item1">
							<u--input v-model="info.tel" type="number" border="none" placeholder="输入联系人手机号码"
							></u--input>
						</u-form-item>
						<u-form-item  label="个人简介" borderBottom ref="item1">
							<u--textarea v-model="info.desc" placeholder="请输入个人简介" ></u--textarea>
						</u-form-item>
						<u-form-item  label="求职内容" borderBottom ref="item1">
							<u--textarea v-model="info.content" placeholder="请输入求职内容" ></u--textarea>
						</u-form-item>
				</u--form>
				<u-action-sheet :show="showType" :actions="typeData" title="选择岗位分类" @close="showType = false" v-show="showType"
					@select="typeSelect">
				</u-action-sheet>
				<u-action-sheet :show="showEdu" :actions="eduData" title="请选择学历要求" @close="showEdu = false" v-show="showEdu"
					@select="eduSelect">
				</u-action-sheet>
				<u-action-sheet :show="showExp" :actions="expData" title="请选择经验要求" @close="showExp = false" v-show="showExp"
					@select="expSelect">
				</u-action-sheet>
				<view class="btns" style="border: 1px solid #5ac725;">
					<view class="confirm" @click="tj"
						:style="{background:app_color}">提交</view>
				</view>
		</view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				info:{
					title:"",
					name:"",
					province:"",
					city:"",
					area:"",
					type:"",
					content:"",
					exp:"",
					edu:"",
					tel:"",
					min_money:3000,
					max_money:5000,
					desc:"",
					sex:"男"
				},
				tagData: [],
				expData: [],
				eduData: [],
				typeData: [],
				showExp: false,
				showEdu: false,
				showType: false,
				radio: '',
				switchVal: false,
				isNormal: true,
				exp:{},
				edu:{},
				type:{}
			}
		},created() {
			this.get()
		},
		onLoad() {
			if(this.param.id){
				this.moxiPost("/plugin/zx/user/jobhunt/get",{id:this.param.id},(data)=>{
					this.info.title = data.data.title;
					this.info.name = data.data.name;
					this.info.province = data.data.province;
					this.info.city = data.data.city;
					this.info.area = data.data.area;
					this.info.type = data.data.type;
					this.info.content = data.data.content;
					this.info.exp = data.data.exp;
					this.info.edu = data.data.edu;
					
					this.info.tel = data.data.tel;
					this.info.min_money = data.data.min_money;
					this.info.max_money = data.data.max_money;
					this.info.desc = data.data.desc;
					this.info.sex = data.data.sex;
				})
			}
		},
		methods: {
			tj(){
				let param = this.info;
				if(this.param.id){
					param.id = this.param.id;
				}
	
				this.moxiPost("/plugin/zx/user/jobhunt/add_job",param,(data)=>{
					this.msg(data.hint);
					setTimeout(()=>{
						uni.redirectTo({
							url: '/pages/plugin/zx/myjob?page_type=zx_qiuzhi'
						});
					},500)
				})
			},
			typeSelect(e) {
				this.info.type = e.key
			},
			change(e) { 
				this.info.province = e.province;
				this.info.city=e.city;
				this.info.area = e.area;
				console.log(e);
			},
			checkboxChange(n) {
				this.tag = n
			},
			eduSelect(e) {
				this.info.edu = e.key
				// this.info.edu = e.value
			},
			expSelect(e) {
				this.info.exp = e.key
				// this.info.exp = e.value
			},
			get() {
				let self = this
				this.moxiPost('/plugin/zx/user/zhaoping/get_config', {}, function(data) {
					if (data.data.edu && self.eduData.length == 0) {
						self.edu = data.data.edu;
						for (let key in data.data.edu) {
							self.eduData.push({
								value: key,
								name: data.data.edu[key],
								key:key
							})
						}
					}
					// console.log('self.eduData ==>', self.eduData);
					if (data.data.exp && self.expData.length == 0) {
						self.exp = data.data.exp;
						for (let key in data.data.exp) {
							self.expData.push({
								value: key,
								name: data.data.exp[key],
								key:key
							})
						}
					}
					// console.log('self.expData ==>', self.expData);
					if (data.data.tag && self.tagData.length == 0) {
						for (let key in data.data.tag) {
							self.tagData.push({
								value: data.data.tag[key],
								name: data.data.tag[key],
								key:key
							})
						}
					}
					
					if (data.data.type && self.typeData.length == 0) {
						self.type = data.data.type;
						for (let key in data.data.type) {
							self.typeData.push({
								value: data.data.type[key],
								name: data.data.type[key],
								key:key
							})
						}
					}
					// console.log('self.typeData ==>', self.typeData);
				})
			},
		}
	}
</script>


<style lang="scss" scoped>
	.btns {
		width: 94%;
		height: 40px;
		display: flex;
		margin: 20px auto;
		border: 1px solid #ccc;
		border-radius: 50px;
		overflow: hidden;
		text-align: center;
		line-height: 40px;

		.reset,
		.confirm {
			
			// width: 50%;
		}
		.reset{border-right: .5px solid #5ac725;background-color: #fff;color: #5ac725;}
		.confirm{
			border-left: .5px solid #5ac725;background: #5ac725;color: #fff;width: 100%;
		}

		.reset {
			border-right: .5px solid #ccc;
		}

		.confirm {
			border-left: .5px solid #ccc;
		}
	}

</style>
